
<h3>related filters</h3>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'qvfilters-grid',
        'dataProvider'=>$qvfmodel->search(),
        'filter'=>$qvmodel,
	'selectionChanged'=>'updateEditFormFilters',
        'columns'=>array(
                array(
                    'value'=>'$data[\'fil_id\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:50px',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadValues')."','data':{'docName':'".strtoupper(Reports::model()->findByPK($_GET['id'])->ber_docName)."','id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'fil_id',
                ),
                array(
                    'value'=>'$data[\'qvf_id\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:30px',
                            'class'=>'qvf_id',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadValues')."','data':{'docName':'".strtoupper(Reports::model()->findByPK($_GET['id'])->ber_docName)."','id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'qvf_id',
                ),
                array(
                    'value'=>'$data[\'qvf\'][\'qvf_fieldName\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:150px',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadValues')."','data':{'docName':'".strtoupper(Reports::model()->findByPK($_GET['id'])->ber_docName)."','id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'QV FieldName',
                ),
		array(
                    'value'=>'$data[\'filter\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadValues')."','data':{'docName':'".strtoupper(Reports::model()->findByPK($_GET['id'])->ber_docName)."','id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'Filter',
                ),
		array(
			'class'=>'CButtonColumn',
                        'template'=>'{delete}',
		),
	),
)); ?>

<script type="text/javascript">

function updateEditFormFilters(target_id){

    $('#Notification').jnotifyAddMessage({
	        text: 'Loading filters...',
	        permanent: false,
	        showIcon: true
   });

    var id =$.fn.yiiGridView.getSelection(target_id);

    $('#fil_save_button').attr('value', (id > 0 ? 'update' : 'create'));

    $.getJSON('<?php echo Yii::app()->createUrl("//qvfilters/subviewload"); ?>'+'&id='+id,
			function(data) {
				$('#Qvfilters_filter').val(data.filter);
                                $('#Qvfilters_fil_id').val(data.fil_id);
                                $('#Qvfilters_rec_id').val(data.rec_id);
                                $('#Qvfilters_qvf_id').multiselect('widget').find('input[value='+ data.qvf_id +']').each(function(){
                                                                                                                           this.click();
                                                                                                                    });
                        });
                        
   return false;
}

</script>

<div id="mySubViewFormFilters">

    <?php $this->renderPartial('//qvfilters/_form', array('filmodel'=>  Qvfilters::model())); ?>

</div>